package com.saas.controller;

import com.saas.pojo.Products;
import com.saas.service.IProductsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController     //URL增删改查时
public class ProductController {

    @Resource
    IProductsService ips;

    @GetMapping("/getAllProducts")
    //URL增删改查
    public List<Products> getAllProducts() {
        return ips.getAllProducts();
    }

    @GetMapping("/GetProductByPid")
    public Products getProductById(@RequestParam Integer id) {
        return ips.getProductById(id);
    }

    @PostMapping("/UpdateProduct")
    public boolean updateProduct(@RequestBody Products product) {
        return ips.updateProduct(product);
    }

    @GetMapping("/DeleteProduct")
    public boolean deleteProduct(@RequestParam Integer id) {
        return ips.deleteProduct(id);
    }

    @PostMapping("/SaveProduct")
    public boolean saveProduct(@RequestBody Products product) {
        return ips.saveProduct(product);
    }

}
